package mahi.generics;

public class OrderedPair<K, V> implements Pair<K, V> {

    private K key;
    private V value;

    public OrderedPair(K key, V value) {
	this.key = key;
	this.value = value;
    }

    public K getKey()	{ return key; }
    public V getValue() { return value; }
    
    
    
    
    public static void main(String[] args) {
		OrderedPair<String, Integer> orderedPair = new OrderedPair<String, Integer>("a", 1);
		OrderedPair<String, Integer> orderedPair1 = new OrderedPair<String, Integer>("b",2);
		System.out.println(compare(orderedPair, orderedPair1));
		
		
//		OrderedPair<String, String> op1 = new OrderedPair<String, String>("a", 1); //Compile time error
//		OrderedPair<String, String> op2 = new OrderedPair<String, String>("b",2);
		
		OrderedPair<String, String> op1 = new OrderedPair<String, String>("a", "c");
		OrderedPair<String, String> op2 = new OrderedPair<String, String>("b","d");
		System.out.println(compare(op1, op2));
		
		
	}
    
    public static <K, V> boolean compare(Pair<K, V> p1, Pair<K, V> p2) {
        return p1.getKey().equals(p2.getKey()) &&
               p1.getValue().equals(p2.getValue());
    }
}
